package com.bw.ppx.frame;

import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.viewbinding.ViewBinding;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.bw.common.entity.LiveDataEntity;
import com.bw.common.mvvm.view.BaseActivity;
import com.bw.ppx.R;
import com.bw.ppx.databinding.ActivityFrameBinding;
import com.google.android.material.bottomnavigation.BottomNavigationView;


@Route(path = "/app/frameactivity")
public class FrameActivity extends BaseActivity<ActivityFrameBinding,FrameViewModel> {
    private AppBottomView appBottomView;
    private NavHostFragment fragment;
    private NavController controller;
    @Override
    public View bindLayout() {
        return v.getRoot();
    }

    @Override
    public ViewBinding initBinding() {
        return ActivityFrameBinding.inflate(inflater);
    }

    @Override
    public void initView() {
        appBottomView = v.frameBottom;
        fragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.frame_fragment);
        controller = fragment.getNavController();
        new NavigationBuilder().create(this,getSupportFragmentManager(),controller,fragment.getId());
        appBottomView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                controller.navigate(item.getItemId());
                return true;
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public String getClassNames() {
        return this.getClass().getName();
    }

    @Override
    protected void handleMessage(LiveDataEntity entity) {

    }
}
